package com.joysuch.wwyt.workflow.controller;


import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.workflow.bean.WorkFlowBizTypeBean;
import com.joysuch.wwyt.workflow.entity.WorkFlowBizType;
import com.joysuch.wwyt.workflow.service.WorkFlowBizTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/workflow/biz-type")
@Api(tags = "业务流程文档引擎-业务类型管理")
@CrossOrigin
public class WorkFlowBizTypeController {

    @Autowired
    private WorkFlowBizTypeService bizTypeService;

    @GetMapping("/list")
    @ApiOperation(value = "获取类型列表(树结构）" )
    public ResultBean list(@RequestParam Long processId) {
       return ResultBean.success(bizTypeService.listTree(processId));
    }


    @GetMapping("/getById")
    @ApiOperation(value = "根据Id查询类型" , response = WorkFlowBizType.class)
    public ResultBean getById(@RequestParam Long id) {
        WorkFlowBizType bizType = bizTypeService.findById(id);
        return ResultBean.success(bizType);
    }


    @GetMapping("/deleteById")
    @ApiOperation(value = "根据Id删除类型")
    public ResultBean deleteById(@RequestParam Long id) {
        return bizTypeService.delete(id);

    }


    @PostMapping("/save")
    @ApiOperation(value = "保存类型" , response = WorkFlowBizType.class)
    public ResultBean save(@RequestBody WorkFlowBizTypeBean bean) {
        return bizTypeService.save(bean);
    }


}
